package com.asp.mapper;

import com.asp.annotation.AutoFill;
import com.asp.dto.PersonTopicPageQueryDTO;
import com.asp.entity.TopicDetail;
import com.asp.entity.User;
import com.asp.enumeration.OperationType;
import com.asp.vo.ShowTopicVO;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;


/**
 * author:          ndg
 * date:            2023/12/29
 */
@Mapper
public interface CenterMapper {

    @AutoFill(value = OperationType.INSERT)
    /*插入 用户数据*/
    @Insert("INSERT INTO tb_user (create_time, update_time, avatar, user_name, password) " +
            "VALUES (#{createTime}, #{updateTime}, #{avatar}, #{userName}, #{password})")
    void insertUser(User user);


    /*根据用户名查询用户*/
    @Select("SELECT * from tb_user where user_name = #{userName}")
    User getByUsername(String userName);

    //跟新用户信息
    @AutoFill(value = OperationType.UPDATE)
    void updateUser(User user);

    @Delete("delete from tb_user where user_name = #{userName}")
    void delete(String userName);

    //@AutoFill(value = OperationType.UPDATE)
    void updateUserName(String oldUserName, String userName);


    Page<ShowTopicVO> pageQueryTopic(PersonTopicPageQueryDTO personTopicPageQueryDTO);

    List<TopicDetail> selectDetail(Integer topicID, String userName);
}
